﻿#ifndef __ASSIST_CROSS_H__
#define __ASSIST_CROSS_H__

#include "qcustomplot.h"
#include "assist_cross_tip.h"

class AssistCross
	: public QCPLayerable
{
public:
    AssistCross(QCustomPlot *plot, QString target_layer = QString(), QCPLayerable *parent_layerable = 0);
    ~AssistCross();

    void RemoveTracer(std::string id);

    void SetTracer(QCPGraph *graph, std::string id);

    void SetCurrentState(bool real_time_flag, double current_point = 0);

    void SetCurrentTracer(double current_point);

    void SetAssistTipWidgetPos(int x, int y);

    void SetAssistTipVisible(bool visible);

    void HideAssistTipWidget();

    void ChangeAssistTracerRealTime(std::string id, QCPGraph *graph);

    void Enable(bool able);
	//辅助线颜色、辅助线标签背景色、辅助文字颜色
	void SetAssistColor(const QString& line_color, const QString& bg_color);

protected:
    void MouseMoveHandle(QMouseEvent *event);

    virtual void applyDefaultAntialiasingHint(QCPPainter *painter) const {}

    virtual void draw(QCPPainter * painter);

private:
	//std::map<std::string, QCPItemTracer*>   tracer_map_;
	QList<QPair<std::string, QCPItemTracer*>> tracer_list_;
    bool                                    real_time_flag_;
    AssistCrossTipWidget                    assist_cross_tip_widget_;   //画图的图例
    int                                     mouse_x_;                   //记录鼠标在plot中的位置
    int                                     mouse_y_;
    QCPItemStraightLine                     *vertical_line_;
    QCPItemStraightLine                     *horizontal_line_;
    bool                                    able_;
	QCustomPlot *plot_;

	QColor _kPlotAssistLineColor;   //辅助十字架
    QColor _kPlotAssistBackgroundColor;   //辅助十字架标签背景色

};

#endif//__ASSIST_CROSS_H__
